<?php

namespace App\Utils\Tools;
use App\Models\VerifyModel;
use Carbon\Carbon;

class CheckEmptyAndValid
{
    /**
     * 验证验证码
     * @param $mobile
     * @param $verify
     * @return bool
     */
    public static function checkVerify($mobile, $verify): bool
    {
        $verifyItem = VerifyModel::where('mobile', $mobile)->orderByDesc('id')->first();
        if (!$verifyItem)
            return false;
        if ($verifyItem->verify != $verify)
            return false;
        if (time() - Carbon::parse($verifyItem->created_at)->getPreciseTimestamp(0) > 300)
            return false;
        return true;
    }
}
